//
//  SSProjectSpecificationView.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/2/24.
//

import UIKit

class SSProjectSpecHeaderView: UIView {
    
    class func headerView()->SSProjectSpecHeaderView{
        return Bundle.main.loadNibNamed("SSProjectSpecHeaderView", owner: nil, options: nil)?.last as! SSProjectSpecHeaderView
    }
    
    var model:ListCombo = ListCombo()
    var secondViewMaxY:CGFloat = 0
    var secondViewH:CGFloat = 0
    
    
    ///init方法，纯代码创建时调用
    override init(frame: CGRect) {
        super.init(frame: frame)
//        setupUI()
    }
    
    
    //init方法，通过xib创建时调用
    required init?(coder: NSCoder) {
        super.init(coder: coder)
//        setupUI()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setupUI()
    }
    
    func setupUI() {
        addSubview(firstPartView)
        addSubview(secondPartView)
        secondPartView.frame = CGRect(x: 0, y: firstPartView.frame.maxY + 16, width: ScreenWidth, height: 80)
    }
    lazy var firstPartView: SSPresentTopView = {
        let firstPartView = SSPresentTopView.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 228))
        return firstPartView
    }()
    
    lazy var secondPartView: SSProjectSpecificationView2 = {
        let secondPartView = SSProjectSpecificationView2.projectSpecificationView()
        return secondPartView
    }()
    
    func setData(model:ListCombo) {
//        model.illustration = "抵抗肌肤看大家反馈抵抗肌肤看大家反馈放66大空间分开多久分开多久分开的第分开的肌肤抵抗肌肤看大家反馈抵抗肌肤看大家反馈放大空间分开多久分开66放假快点放假快点放假咖啡放的开房间00大哭司法鉴定所"
//        self.secondPartView.describeLab.backgroundColor = UIColor.red
//        self.secondPartView.backgroundColor = UIColor.blue
//        self.backgroundColor = UIColor.green
        self.model = model
        self.secondPartView.titleLab.text = model.name
        self.secondPartView.priceLab.text = "$\(model.fee)起"
        self.secondPartView.setData(model: model)
        secondViewMaxY = secondPartView.frame.maxY + 10
        secondViewH = secondPartView.frame.height
    }
    func setype(type:String) {
        firstPartView.setType(type: type)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        print("---secondPartView.frame.maxY1:\(secondPartView.frame.maxY)")
        print("---headerViewFrame:\(frame)")
        self.frame.size = CGSize(width: frame.width, height: secondViewMaxY)
        secondPartView.frame.size = CGSize(width: secondPartView.frame.width, height: secondViewH)
    }
    
}
